package com.fulu.game.bi.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 资金平台枚举表
 */
public enum PlatformCashEnum {
    ;

    @Getter
    @AllArgsConstructor
    public enum CashTypeEnum {
        INVEST(1, "充值", "cash_invest_realtime_stat", PlatformCashEnum.InvestEnum.values()),
        CONVERT(2, "兑换", "cash_convert_realtime_stat", PlatformCashEnum.CovertEnum.values()),
        REFUND(3, "退款", "cash_refund_realtime_stat", PlatformCashEnum.RefundEnum.values());

        private Integer type;
        private String name;
        private String table;
        private TypeEnum<Integer>[] typeEnums;

        public static CashTypeEnum getByType(Integer type) {
            for (CashTypeEnum e : CashTypeEnum.values()) {
                if (Objects.equals(e.getType(), type)) {
                    return e;
                }
            }
            return null;
        }
    }

    @Getter
    @AllArgsConstructor
    public enum InvestEnum implements TypeEnum<Integer> {
        WEIXIN(1, "微信充值"),
        ALIPAY(2, "支付宝充值"),
        APPLE(3, "苹果内购充值"),
        OPEN(4, "开发平台充值");

        private Integer type;
        private String msg;

        public static PlatformCashEnum.InvestEnum getEnum(Integer type) {
            for (PlatformCashEnum.InvestEnum e : PlatformCashEnum.InvestEnum.values()) {
                if (Objects.equals(e.getType(), type)) {
                    return e;
                }
            }
            return null;
        }

        @Override
        public TypeEnum<Integer> parse(Integer type) {
            for (PlatformCashEnum.InvestEnum e : PlatformCashEnum.InvestEnum.values()) {
                if (Objects.equals(e.getType(), type)) {
                    return e;
                }
            }
            return null;
        }
    }

    @Getter
    @AllArgsConstructor
    public enum CovertEnum implements TypeEnum<Integer> {
        ORDER_TO_PIPI(1, "皮皮币-订单收益兑换"),
        GUILD_ORDER_TO_PIPI(2, "皮皮币-公会订单收益兑换"),
        GUILD_CHARM_TO_PIPI(3, "皮皮币-公会魅力值收益兑换"),
        PIPI_TO_DIAMOND(4, "钻石-皮皮币兑换"),
        CHARM_TO_DIAMOND(5, "钻石-魅力值兑换"),
        GUILD_ORDER_TO_DIAMOND(6, "钻石-公会订单收益兑换"),
        GUILD_CHARM_TO_DIAMOND(7, "钻石-公会魅力值收益兑换");

        private Integer type;
        private String msg;

        public static PlatformCashEnum.CovertEnum getEnum(Integer type) {
            for (PlatformCashEnum.CovertEnum e : PlatformCashEnum.CovertEnum.values()) {
                if (Objects.equals(e.getType(), type)) {
                    return e;
                }
            }
            return null;
        }

        @Override
        public TypeEnum<Integer> parse(Integer type) {
            for (PlatformCashEnum.CovertEnum e : PlatformCashEnum.CovertEnum.values()) {
                if (Objects.equals(e.getType(), type)) {
                    return e;
                }
            }
            return null;
        }
    }


    @Getter
    @AllArgsConstructor
    public enum RefundEnum implements TypeEnum<Integer> {
        TOTAL(1, "总退款"),
        ORDER(2, "订单退款"),
        APPLE(3, "苹果内购退款");

        private Integer type;
        private String msg;

        public static PlatformCashEnum.RefundEnum getEnum(Integer type) {
            for (PlatformCashEnum.RefundEnum e : PlatformCashEnum.RefundEnum.values()) {
                if (Objects.equals(e.getType(), type)) {
                    return e;
                }
            }
            return null;
        }

        @Override
        public TypeEnum<Integer> parse(Integer type) {
            for (PlatformCashEnum.RefundEnum e : PlatformCashEnum.RefundEnum.values()) {
                if (Objects.equals(e.getType(), type)) {
                    return e;
                }
            }
            return null;
        }
    }
}
